<%@page pageEncoding="UTF-8" %>

<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Iterator"%>
<%@page import ="com.sxt.bbs.db.DB"%>
<%@page import = "com.sxt.bbs.entity.Article" %>
<%@page import = "java.sql.Connection" %>
<%@page import = "java.sql.Statement" %>
<%@page import = "java.sql.ResultSet" %>
<%@page import = "java.sql.SQLException" %>
<%@page import = "java.util.List" %>
<%@page import = "java.util.ArrayList" %>

<%!
private void tree(List<Article> articles, Connection conn, int id, int grade) {
	String sql = "select * from article where pid = " + id;
	Statement stat = DB.createStat(conn);
	ResultSet rs = null;
	try {
		rs = DB.excuteQuerey(stat, sql);
		while(rs.next()) {
			Article articleTemp = new Article();
			articleTemp.initFromRS(rs);
			articles.add(articleTemp);
			articleTemp.setGrade(grade);
			if(!articleTemp.isIsleaf()) {
				tree(articles, conn, articleTemp.getId(), grade + 1);
			}
		}
	} catch(SQLException e) {
		e.printStackTrace();
	} finally {
		DB.close(rs);
		DB.close(stat);
	}
}
%>

<%
List<Article> articles = new ArrayList<Article>();
Connection conn = DB.getConn();
tree(articles, conn, 0, 0);
DB.close(conn);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0037)http://bbs.51cto.com/forum-133-1.html -->
<html  xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Java论坛 -  51CTO技术论坛_中国领先的IT技术社区</title>
<link  rel="archives"  title="51CTO技术论坛_中国领先的IT技术社区"  href="http://bbs.51cto.com/archiver/" />
<link  href="./page_style/global.css"  rel="stylesheet"  type="text/css"/>
<link  href="./page_style/map_menu.css"  rel="stylesheet"  type="text/css" />
<link  href="./page_style/style.css"  rel="stylesheet"  type="text/css"/>
<link  href="./page_style/sidebar.css"  rel="stylesheet"  type="text/css"/>
<style  type="text/css"></style>

<link  href="./page_style/art_master_top.css"  rel="stylesheet"  type="text/css"/>
<style  type="text/css"></style>

</head>
<body>

<div  class="first"><a  href="http://bbs.51cto.com/"  target="_blank"  class="logo"><img  src="./page_style/logo.jpg"/></a> </div>

<div  class="w960">
  <div  class="row01z">
    <div  class="wlgl">
      <div  class="wlgl_tit">
        <h3  id="cdis">Java论坛</h3>
      </div>
      <div  class="banz"></div>
    </div>
  </div>
  <div  class="clear hr10"></div>
</div>
<div  id="ad_plate"></div>
<div  class="tabbox">
  <div  class="tab_z01"> <a  class="sd03 fl"  href="http://bbs.51cto.com/forumdisplay.php?fid=133">全部主题</a></div>
  <div  class="fr"  style="width:308px;">
    <div  class="btnbox"  id="newspecial"> <a  href="post.jsp"  title="发新话题"> <img  src="./page_style/newtopic_hov.gif"  class="fr"/> </a>
      <div  id="newspecial_menu"  style="display:none;"  class="tw_float">
        <ul>
          <li><a  href="post.jsp"><img  src="./page_style/folder_s.gif"  />发新话题</a></li>
        </ul>
      </div>
    </div>
  </div>
</div>
<div  class="clear"></div>
<div  class="t_main"  style="position:relative;">
  <div  class="t_main01">
    <div  class="t_header">
      <p  class="t_author">作者</p>
      <p  class="t_reply">回复/查看</p>
      <p  class="t_lastPost">最后发表</p>
    </div>
  </div>
  <div  class="trbg"  china="主贴列表">
    <table  width="100%"  border="0"  cellspacing="0"  cellpadding="0"  align="center"  id="mytable">
      <tbody>
      
       <%
		for(Iterator<Article> it = articles.iterator(); it.hasNext();) {
			Article articleTemp = it.next();
			String pStr = "";
			for(int i = 0; i < articleTemp.getGrade(); i++) {
				pStr += "-----";
			}
		%>
				
      
        <tr>
          <td  colspan="8"  align="center"  valign="middle"  id="fjx"  class="fjx"></td>
        </tr>
        <tr  class="t_item">
          <td><a href="delete.jsp?id=<%=articleTemp.getId() %>&pid=<%=articleTemp.getPid() %>">DEL</a></td>
          <td  width="27"  align="center"  valign="middle"><a  href="javascript:void(0)"></a></td>
          <td width="32"  colspan="3"  align="left"  valign="middle"  class="common"><span  id="thread_1139316"> <a  href="article_detail.jsp?id=<%=articleTemp.getId() %>"  target="_blank" ><%=pStr + articleTemp.getTitle() %></a> </span></td>
          <td  width="120"  align="left"  valign="middle"  class="by"><a  href="http://bbs.51cto.com/space-uid-9737346.html">程序_1011</a> <br/>
            <%=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(articleTemp.getTimeStamp())%></td>
          <td  width="70"  align="left"  valign="middle"  class="td03"><a  href="http://bbs.51cto.com/thread-1139316-1.html"  target="_blank">348</a> <br/>
            6437 </td>
          <td  width="130"  align="left"  valign="middle"  class="by"><a  href="http://bbs.51cto.com/space-username-doggiejohn.html">doggiejohn</a> <br/>
            2015-06-17 20:30:13 </td>
        </tr>
        
        <%
         }
        %>
        
      </tbody>
    </table>
  </div>
  <div  class="clear"></div>
</div>
<div  class="pagebox">
  <ul>
    <li><a  class="abg">1</a></li>
    <li><a  href="http://bbs.51cto.com/forum-133-2.html"  class="next">下一页</a></li>
  </ul>
</div>
<div  style="display:none">  
</div>
</body>
</html>